<%--
/**
* Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
--%>

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

<portlet:defineObjects />

<%@include file="/html/init.jsp" %>

<%
	String redirect = PortalUtil.getCurrentURL(renderRequest);	
	
	boolean hasAddPermission = permissionChecker.hasPermission(
			scopeGroupId, "com.liferay.library.model",
			scopeGroupId, "ADD_PUBLISHER");
	boolean hasConfigurePermission = permissionChecker.hasPermission(
			scopeGroupId, Group.class.getName(), scopeGroupId,
			ActionKeys.PERMISSIONS);

	    	
%>

<aui:button-row>
	<portlet:renderURL var="addPublisherURL">
		<portlet:param name="jspPage" value="/html/publisherportlet/edit_publisher.jsp" />
		<portlet:param name="redirect" value="<%= redirect %>" />
	</portlet:renderURL>

	<c:if test='<%= hasAddPermission %>'>
		<portlet:renderURL var="addPublisherURL">
			<portlet:param name="jspPage" value="/html/publisherportlet/edit_publisher.jsp" />
			<portlet:param name="redirect" value="<%= redirect %>" />
		</portlet:renderURL>

		<aui:button value="add-publisher" onClick="<%= addPublisherURL.toString() %>"/>
	</c:if>
	<c:if test='<%= hasConfigurePermission %>'>
		<liferay-security:permissionsURL
		  modelResource="com.liferay.training.library.model"
		  modelResourceDescription="library-top-level-actions"
		  resourcePrimKey="<%= String.valueOf(scopeGroupId) %>"
		  var="permissionsURL"
		/>

		<aui:button value="permissions" onClick="<%= permissionsURL %>"/>
	</c:if>	 

   
</aui:button-row>


	    

<liferay-ui:search-container delta='<%= GetterUtil.getInteger(prefs.getValue("rowsPerPage", "5")) %>' emptyResultsMessage="publisher-empty-results-message">
	<liferay-ui:search-container-results
		results="<%= PublisherLocalServiceUtil.getPublishersByGroupId(scopeGroupId, searchContainer.getStart(), searchContainer.getEnd()) %>"
		total="<%= PublisherLocalServiceUtil.getPublishersCountByGroupId(scopeGroupId) %>"
	/>

	<liferay-ui:search-container-row
		className="com.liferay.library.model.Publisher"
		keyProperty="publisherId"
		modelVar="publisher"
	>
		<liferay-ui:search-container-column-text
			name="name"
			value="<%= publisher.getName() %>"
		/>

		<liferay-ui:search-container-column-text
			name="email-address"
			property="emailAddress"
		/>

		<liferay-ui:search-container-column-text
			name="phone-number"
			property="phoneNumber"
		/>

		<liferay-ui:search-container-column-text
			name="website"
			property="website"
		/>

		<liferay-ui:search-container-column-jsp
			align="right"
			path="/html/publisherportlet/publisher_actions.jsp"
		/>
	</liferay-ui:search-container-row>

	<liferay-ui:search-iterator />
</liferay-ui:search-container>
